<%@ page pageEncoding="UTF-8" %>
<%@ page import="buscar.Materia" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'materia.label', default: 'Materia')}" />
        <title>Listar Matéria</title>
        <style>
        .body{width: 40%; text-align: center; position: relative;}
        td {text-align: left;}
        .reduz {width: 20px;text-align: center;}       
        </style>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span>
        </div>
        <div class="body">
            <h1>Listar Matéria</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                        
                            <g:sortableColumn property="id" title="${message(code: 'materia.id.label', default: 'Id')}" />
                        
                            <g:sortableColumn property="titulo" title="${message(code: 'materia.titulo.label', default: 'Titulo')}" />
                        
                            
                            <g:sortableColumn property="Editar" title="Editar" />
                            
                            <g:sortableColumn property="excluir" title="Excluir" />
                        
                        </tr>
                    <tbody>
                    <g:each in="${materiaInstanceList}" status="i" var="materiaInstance">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                        
                            <td class="reduz">${fieldValue(bean: materiaInstance, field: "id")}</td>
                        
                            <td><g:link action="show" id="${materiaInstance.id}">${fieldValue(bean: materiaInstance, field: "titulo")}</g:link></td>
                        
                            <td class="reduz">
                            <g:form>
                    			<g:hiddenField name="id" value="${materiaInstance?.id}" />
                    			<g:actionSubmit class="edit" action="edit" value="${message(code: 'default.button.edit.label', default: 'Edit')}" /> <!-- img src="/buscar/images/materia/editar_materia.jpeg"/ -->
                			</g:form>
                			</td>
                            <td class="reduz">
                            	<g:form>
                    				<g:hiddenField name="id" value="${materiaInstance?.id}" />
                    				<g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
                				</g:form>
                            </td>
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${materiaInstanceTotal}" />
            </div>
        </div>
    </body>
</html>
